package com.szt.sy.controller.blog.siteinfo;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import com.szt.sy.anontation.Authority;
import com.szt.sy.anontation.AuthorityConfig;
import com.szt.sy.common.AuthorityCommon;
import com.szt.sy.controller.base.AdminBaseController;
import com.szt.sy.entity.blog.SiteInfo;
import com.szt.sy.service.blog.siteinfo.SiteInfoService;
import com.szt.sy.vo.rep.base.RepBaseVO;

/***
 * 网站信息-controller
 * 
 * @author wwy
 *
 */
@Controller
@AuthorityConfig(prefix = "/admin/siteinfo/edit")
@RequestMapping(value = "admin/siteinfo")
public class SiteInfoController extends AdminBaseController {
	/***
	 * 菜单地址(权限用)
	 */
	final String menuUrl = "/admin/siteinfo/edit";
	@Autowired
	private SiteInfoService siteinfoService;
	
	/**
	 * 去修改页面
	 *
	 * @param @
	 */
	@Authority(name = AuthorityCommon.EDIT)
	@GetMapping(value = "/edit")
	public ModelAndView goEdit() {
		ModelAndView mv = this.getModelAndView();
		
		SiteInfo entity = siteinfoService.getSiteInfo();
		mv.setViewName("blog/siteinfo/siteinfo_edit");
		mv.addObject("msg", "edit");
		mv.addObject("entity", entity);
		return mv;
	}
	
	/**
	 * 修改
	 *
	 * @param @
	 */
	@Authority(name = AuthorityCommon.EDIT)
	@PostMapping(value = "/edit")
	@ResponseBody
	public RepBaseVO edit(SiteInfo entity) {
		RepBaseVO repVO = new RepBaseVO<>();
		siteinfoService.updateById(entity);
		return repVO.setCommonSuccess();
	}
	
}
